from housecentapp.models import Tags, Houses, Cities
def housesget(cityname,tags):
    mytags=tags.split(",")[:-1]
    print(mytags)
    city = Cities.objects.filter(name=cityname).first()
    houses = Houses.objects.filter(city=city)
    elhouses=[]
    for house in houses:
        if not mytags:
            elhouses=houses
            break
        tags=house.tags_set.all()
        for tag in tags:
            if str(tag.id) in mytags:
                elhouses.append(house)
                break
    return elhouses